Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimise ROTable accesses and interface #2505

Merged
merged 2 commits into from
Oct 13, 2018
Merged

Conversation

TerryE
Copy link
Collaborator

@TerryE TerryE commented Oct 4, 2018

Addresses Issue #2504

  • This PR is for the dev branch rather than for master.
  • This PR is compliant with the other contributing guidelines as well (if not, please describe why).
  • I have thoroughly tested my contribution.

See #2504 for detailed discussion of the background and scope of this patch. There isn't any change at an application level, apart from making ROTable access times comparable to RAM Table access times. The code changes therefore don't impact the documentation at docs/en/* excepting the following points:

  • We might want to mention the speedup in the FAQ, but this is due a major update anyway.
  • We might want to document how you can list off the installed ROM libraries by enumerating pairs(_G.__index).

@TerryE TerryE requested review from jmattsson and pjsg October 4, 2018 12:15
unsigned hash;
unsigned addr:24;
unsigned ndx:8;
} cache[LA_LINES][LA_SLOTS];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eeep! That's half a K right there, isn't it? :(
Could this be an optional feature, so those really tight on RAM can opt for the performance hit instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was the ½K ☺️ I can make move it from static to dynamic, but we'll always need it - or at least the cache if we want fast ROTable access. I can half the line size with my next step on this journey.

I'll also do the claw- back on DNS on this patch so we don't lose net RAM.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No don't make it dynamic. This is something which if it's in use, it should be statically allocated to ensure it's there when needed. Plus it makes it easier to reason about other RAM usage.

If you can reclaim RAM from elsewhere so the net available stays the same, that would be Very Good :) And if half the size is enough for the common scenarios, that sounds good too!

/*
* The invariants for 1st word comparison are deferred to here since they
* aren't needed if there is a cache hit. Note that the termination null
* is included so a "on\0" has a mask of 0xFFFFFF and "a\0" has 0xFFFF.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this comment :)

@TerryE
Copy link
Collaborator Author

TerryE commented Oct 5, 2018

@jmattsson, the lookaside cache seems to work well. "How big should we make it" is a useful Q to ask. 8 x 4 seems to be a good compromise, and most real life Lua applications rarely use anything like 32 ROTable fields, so the hit rates should be pretty good -- in the 99% ballpark, which effectively eliminates the search overhead for normal field access.

We still have this issue of cases where the VM does existence checks for fields such as __metatable and __index. I can add some extra instrumentation to my luac.cross -e build to see if this is an issue in practice.

@marcelstoer marcelstoer added this to the Next Release milestone Oct 5, 2018
Some refinements to the ROTable cache which remove the linker cludges
on the CROSS_COMPILE builds.  Also keyhole tweaks to some of the
Lua VM code to implrove runtimes.

I also noticed some compile time warnings during the build; the change
to uz_unzip.c doesn't impact the compiled code, but does remove the
compiler warnings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants