Skip to content

Slurp WPTs into core a la .lists #42

Closed

Description

@yakra

Slurp WPTs into core and use strtok, as done with .lists.
See if there's a speed increase.
What's the largest WPT file I'd have to contend with? (rus.ah006irk.wpt, at 58882 bytes.)

Activity

  1. yakra commented on Jan 4, 2019

    @yakra
    OwnerAuthor

    If this works out well (or even if not?) try a more C-string-based approach for the TravelerList ctor.

  2. yakra commented on Jan 5, 2019

    @yakra
    OwnerAuthor

    See if there's a speed increase.

    Nope. Slower by ~0.3 s.
    MAYBE revisit this when datachecks are moved into read_wpt -- to give each thread something more to do than just wait on strtok_mtx.

    If this works out well (or even if not?) try a more C-string-based approach for the TravelerList ctor.

    Still worth looking into.

  3. yakra commented on Jan 5, 2019

    @yakra
    OwnerAuthor

    If this works out well (or even if not?) try a more C-string-based approach for the TravelerList ctor.

    .list file processing ~7.2s -> ~6.6s

  4. yakra commented on Jan 5, 2019

    @yakra
    OwnerAuthor

    MAYBE revisit this when datachecks are moved into read_wpt -- to give each thread something more to do than just wait on strtok_mtx.

    Closing this issue now, and hoping I'll remember that when the time comes.

  5. yakra commented on Jan 6, 2019

    @yakra
    OwnerAuthor

    a potential alternative to strtok, which avoids the need for a mutex:

    size_t spn = 0;
    for (char *c = foo; *c; c += spn)
    {	spn = strcspn(c, "\r\n");
    	while (c[spn] == '\r' || c[spn] == '\n')
    	{	c[spn] = 0;
    		spn++;
    	}
    	container.push_back(c);
    }
  6. reopened this on Jan 6, 2019
  7. changed the title [-]Slurp WPTs onto core a la .lists[/-] [+]Slurp WPTs into core a la .lists[/+] on Jan 6, 2019
  8. yakra commented on Jan 6, 2019

    @yakra
    OwnerAuthor

    Not useful in WPT file processing. Adds ~0.1-0.2 s compared to 16.7 s.

    Give it a try in .list file processing.
    Test outer loop, inner loop, both, and none.
    (May be more useful in outer loop?)

  9. yakra commented on Jan 6, 2019

    @yakra
    OwnerAuthor

    Saves 0.1s. Sometimes. Not even that is consistent.
    Leaving as-is; keeping it simple.

    May be worth revisiting once multithreading is implemented on noreaster, where more cores can get hung up waiting for strtok_mtx

    Until then, closing for housekeeping purposes.

  10. yakra commented on Jan 31, 2019

    @yakra
    OwnerAuthor

    Could this make up for slow reading on a fresh run before WPTs are in the hard disk's cache? List file processing goes much faster.

  11. reopened this on Jan 31, 2019
  12. yakra commented on Feb 13, 2019

    @yakra
    OwnerAuthor

    Reading waypoints for all routes:

    • dry run: 74.6 s (fresh from a cold boot)
    • wet run: 14.6 s (immediately after)

    Processing traveler list files:

    • dry run: 6.9 s (fresh from a cold boot)
    • wet run: 6.7 s (immediately after)

    We can see that .list files don't suffer from nearly the same slowdown as WPTs.
    (Heck, what's our margin of error here?)

  13. yakra commented on Feb 13, 2019

    @yakra
    OwnerAuthor

    WPT files: 61.7 MB (note: this figure is inflated a bit by 701 unprocessed wpt files)
    Reading WPTs: 0.827 MBps dry -> 4.226 MBps wet

    WPT files: 61 MB (without unprocessed wpt files)
    Reading WPTs: 0.818 MBps dry -> 4.178 MBps wet

    list files: 6.3 MB
    Reading lists: 0.913 MBps dry -> 0.940 MBps wet

  14. yakra commented on Feb 14, 2019

    @yakra
    OwnerAuthor

    List file processing goes much faster.

    Or does it? Not necessarily...
    I was misled by watching my CPU History graph churn away at 100%, concluding that disk access was no longer a major bottleneck here. The reason for this, though, is not faster disk reading, but that .list processing is a more CPU intensive task, and is already (or at least, darn close to, for a dry run) our bottleneck. We see this in the redlined CPUs while averaging much lower read speeds for the task at hand.

    Nonetheless, it seems we can get somewhat faster read speeds using the "slurp+strtok" method, and I have to wonder what this could look like for a less CPU-bound task.
    It's worth giving this another look.

  15. yakra commented on Feb 14, 2019

    @yakra
    OwnerAuthor

    Another attempt, same code:
    wpts: 82.3s @ 0.741 MBps -> 14.3s @ 4.266 MBps
    Lists: 7.0s @ 0.900 MPbs -> 6.6s @ 0.955 MBps

    List files, on a dry run, have CPU use hovering just a touch below 100%, with speed increasing marginally on a wet run. This suggests we're just below the CPU bottleneck threshold on a dry run, and shouldn't expect much more than 0.913 MBps on a dry run, or less than 66.8s .list processing time.
    I'll try it out anyway...

  16. yakra commented on Feb 14, 2019

    @yakra
    OwnerAuthor

    "slurp+strtok":
    wpts @ 74.5s dry.
    Only 0.1s better than the 1st attempt with the old code.
    OTOH, 7.8s better than the 2nd attempt, down about 9.5s.
    Too close to call; gonna make another attempt.

  17. yakra commented on Feb 14, 2019

    @yakra
    OwnerAuthor

    hard disk, 4 threads

    attempt getline
    dry
    strtok
    dry
    getline
    wet
    strtok
    wet
    A 74.6 74.5 14.6 (?)
    B 82.3 73.4 14.3 14.2
    C 75.5 71.3 14.7 14.5
    D 90.0 73.6 14.4 14.4
    E 75.0 73.3 14.5 14.4
    F 84.2 75.1 14.3 14.4
    G 74.2 71.3 14.5 14.3
    H 73.5 72.4 14.2 14.4
    I 82.2 72.3 14.5 14.2
    J 74.1 73.8 14.5 14.6

    thumb drive, 4 threads

    attempt getline
    dry
    strtok
    dry
    getline
    wet
    strtok
    wet
    K 309.5 272.2 14.3 14.4

    thumb drive, 1 thread

    attempt getline
    dry
    strtok
    dry
    getline
    wet
    strtok
    wet
    L 247.0 360.3 16.7 17.7

    Thumb drive: read times look highly variable, with reading method & number of threads not having significant effect. All four dry runs were punctuated by long periods (sometimes close to a minute) of very slow progress, with the CPU meter essentially at 0%. The behavior was sometimes observed reading .lists, sometimes not.
    With the read times involved, I will not test further.

    Hard disk: strtok method does have a slight advantage, so in it goes, unless there's a big RAM use difference, which I don't think there'll be. I'll have a look.

  18. yakra commented on Feb 17, 2019

    @yakra
    OwnerAuthor

    Both versions top out at 69.5% of 3.8GiB.
    Using strtok.
    Keeping strtok_mtx and not using the homebrew mutex-less solution above, to just keep it simple.
    No harm to speed here, as this is an I/O-bound task. On BiggaTomato, at least. The situation might be different on noreaster, but I'll cross that bridge later.

  19. yakra commented on Apr 8, 2020

    @yakra
    OwnerAuthor

    No harm to speed here, as this is an I/O-bound task.

    Is not in fact I/O-bound on a wet run. Rather, at the time the statement was made, by all_waypoints.mtx, which has since been made much more efficient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions