-
Notifications
You must be signed in to change notification settings - Fork 26
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
Matrix box carousels #1598
base: main
Are you sure you want to change the base?
Matrix box carousels #1598
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
That makes sense, yeah, it's a lot. Definitely worth checking how this
affects performance!
…On Thu, Sep 7, 2023 at 12:16 AM andrew nimmo ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In app/presenters/matrix_box_presenter.rb
<#1598 (comment)>
:
> if target&.respond_to?(:thumb_image) && target&.thumb_image
self.image_data = {
- image: target.thumb_image,
- image_link: target.show_link_args,
+ images: target.images,
Quite a bit more loading. It now has to be { images: [:image_votes,
:license, :user] }
—
Reply to this email directly, view it on GitHub
<#1598 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAYTNNOOPIKSDPHEBBHR6PDXZFDCXANCNFSM6AAAAAA4OHS4KY>
.
You are receiving this because your review was requested.Message ID:
***@***.***
com>
|
In terms of manual testing, please make sure the "hot" areas of the matrix_box images make sense and are usable. There are quite a few of them for such a small area.
It would also be nice to benchmark the load time for this page vs. main. Volunteers encouraged! |
Is Chrome version 116.0.5845.179 (Official Build) (x86_64) vagrant@ubuntu-focal:/vagrant/mushroom-observer$ git log -1
commit a1eb3c639a42b24f4e70f6f4584be715bc609c52 (HEAD -> nimmo-matrix-box-carousels, origin/nimmo-matrix-box-carousels)
Merge: 237e2d533 d4d57f962
Author: andrew nimmo <andrnimm@fastmail.fm>
Date: Thu Sep 7 13:19:48 2023 -0700
Merge branch 'main' into nimmo-matrix-box-carousels
|
@JoeCohen - you're right, the obs_link is not on the carousels. I agree, it's ok this way. |
@JoeCohen ... aha, i figured out where I'd experimentally disabled it. The obs_link is back working now. If you have time to check it out, please let me know if you think that's better or not. I do feel like people expect it at this point, but maybe not. |
It's all good. (The obs_link works fine in the carousel.)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @nathan says, sweet.
Overall I think this looks great, but since you asked, here is some criticism. I don't know how to do this in a way that doesn't sound like a litany of negative complaints, sorry. Best I could do is express them as requests and/or preferences. Hope that's good enough!
and
Since they are mostly repeats, they are cached and take < a millisecond, so maybe "who cares?" But this feels like something that could become important later when it may be less easy to catch. Or maybe it will go away on its own without us ever having to deal with. Clearly this is not ideal, but maybe not a problem. For now, just a note.
|
PS. re: performance -- I just realized that my laptop blazes compared to the production server, so my back-of-the-envelope calculations leading me to conclude that those superfluous(?) cached queries are inconsequential may not be accurate estimates of real cost. PPS. I'm running firefox 116.0.3 on ubuntu 5.15.0-82. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
I'm not sure which of my code you're referring to regarding count vs. length, but it wouldn't surprise me if I got it wrong somewhere. I looked through my last two PRs and didn't see anything obvious. However, the rule as I understand it is that As a side note, all of the above primarily applies to application code. Test code is a bit different. There may well be good reason to reconsult the database using Does any of that address the question? |
Looking at the visual group code, the only place where I see
In this case I would argue that |
Thanks @mo-nathan. That example you gave from # Has anyone proposed a given Name yet for this observation?
def name_been_proposed?(name)
namings.count { |n| n.name == name }.positive?
end How about: # Has anyone proposed a given Name yet for this observation?
def name_been_proposed?(name)
namings.where(name: name).present?
end This seems pretty minimal. You're right - the hits I found in your visual groups were a false positive, those should stay as they are. Will add all this to a GitHub Discussion so it's available for reference. |
For:
I find the alternative code you propsed to be clearer. Testing it out, it does appear that the namings are already loaded, so your code does generate an extra query over the existing code. In this case I don't think that really matters since the amount of data is very small. If it did, I'd lean towards |
Thanks for the explanation. I will revert that change on the other PR then, because that PR is all about removing extra queries, even small ones. |
I tried this out and found that on my local o airport wifi, it was noticeably slower both using the developer tools and my own user experience. I think it went up from about 1.5 seconds to 2.5 seconds for the initial load and then the image loads felt a bit slower as well. For me the extra time didn't really feel worth it, but I expect I'd adapt to it. Unfortunately the internet is bad enough here that I can't really get more precise timing data. |
I definitely want to sort this out. This was the original thing that i noticed. Why are
Need to fix!
This is restored now on the current branch of this PR.
This was a longstanding request of Alan's. I don't mind it like this (i.e. as he requested), but it's easy to change.
Will check this, not sure it's showing like that for me.
Will consider adding a link to the obs in the lightbox. |
Was able to get some better data. On main I was seeing the initial page load at just over 2 seconds with subsequent loads at 1.6 seconds. On this branch the initial load was just over 3 seconds with subsequent loads around 2.6 seconds. |
@nimmolo -- I can take a closer look at the queries on the home page tomorrow maybe. I confess that I get a bit lost now that you've reorganized all of my code so thoroughly! ;) But I gotta learn what you've done eventually... Also re: expando box scrolling continuously through all the observations -- I was thinking (for a future PR!) that one way to have the best of all worlds would be to have an animation of some sort "swipe" between images, and then add some sort of obvious spacer between the last image of the observation you're on and the first image of the next observation. That would be more than enough of a visual clue to keep me happy. I don't need much, just throw me the occasional crumb. ;) Just anything to signal to the viewer that they're moving on to another observation. |
I woke up way too early and couldn't get back to sleep, so I ran some more tests from my hotel room wifi. This branch is still consistently slower for me than I also noticed that on the branch there a bunch of addition redundant SQL queries that look like this: |
This comment was marked as outdated.
This comment was marked as outdated.
Ohhh... yep. I got it now. You've got an older DB snapshot, like Jason, I bet. I went back to the index near what's "current" for his snapshot, and yes I do get the weird extra queries.
To me the suspect place might be my refactor of the show_obs_title and related helpers in |
Aha. I believe the problem occurs in the lightbox printing the observation title with ALL the bells and whistles including preferred name link, owner naming, deprecated name... And then there's the observation-details section below it, with so many links there too. It was convenient to grab that partial for the lightbox caption, but maybe what we need instead is something like the obs details in plain text with no links, and a single link to the obs. |
To reproduce the issue, go to http://localhost:3000/505457, and then hit "Index" to be sure we're on the same page of the index. Many extra queries will fire. If you examine the lightbox caption for that observation (it's encoded as a data-attribute in each image) you'll find the ID's of some of the associations that are firing the extra queries. This is an issue in the lightbox currently, and it's being multiplied by having more images on the index. I'll try a separate PR to simplify the lightbox caption text, upstream, outside of this carousel PR. |
Experimentally merging the lightbox caption PR into this to check if it helps. |
Yes! Simplify the lightbox caption! It would totally make sense that's where some of this project-related stuff is coming from. So glad you found that. |
Ok. It does seem to fix it, but I will sit on this PR until I hear more from you guys about performance. I'm amazed that Nathan can cold load the index in 3 or 4 seconds on main — on my machine it takes a minimum 25 seconds! Consider also that Rails 7 will allow lazy loading of each matrix-box. That PR is my higher priority, and it may be that we will be happier with carousel performance in that case. I'm also in no rush with this version of the carousels because i don't like the way it has to shrink the vertical images back to where they were a year ago. The Stimulus "swiper" carousel that's available on 7 can use variable height. On the other hand, as Jason pointed out earlier, getting carousels up may save untold trips to show obs. |
Also as shown in the images, the database I'm running on is from September 7 and I have it configured to display 144 images. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
I am unable to reproduce any weird query issue, and i've paged through the first 15 pages of 150 obs each on the current version of this branch, with a snapshot from 2023-03-02, the latest on the image server last week. Note that many images are expected to keep loading after page load, because they're lazy loaded. Other assets seem to be getting lazyloaded too, like icons and arrows, and I don't know why that would be, but it's probably not different from main, nothing has changed in any config that I know of. Nathan's using a newer snapshot than I have, though. I'm not sure what's different there. The screenshots show the image loads but not the queries. |
Hey, I just got done with what I was doing tonight. I'll take a look and
see if I can track this down, because I was able to reproduce it earlier.
…On Mon, Sep 11, 2023 at 11:48 PM andrew nimmo ***@***.***> wrote:
I am unable to reproduce any weird query issue, and i've paged through the
first 15 pages of 150 obs each on the current version of this branch.
Note that images are expected to keep loading after page load, because in
most cases they're lazy loaded. Other assets are getting lazyloaded too,
like icons and arrows, and I don't know why that would be but it's probably
not different on this branch.
Nathan's using a newer snapshot than I have, though. I'm not sure what's
different there. The screenshots don't show the queries
—
Reply to this email directly, view it on GitHub
<#1598 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAYTNNJUQTNSGSJGERA2Z5DXZ7LQ7ANCNFSM6AAAAAA4OHS4KY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I found the problem with the projects. There are two things that require projects:
I fixed it so that it doesn't need to eager-load observations.thumb_image. It's already eager-loading all of the images, so there's no reason to eager-load the thumbnail twice. Lastly, I noticed that the carousels really slow down the page a lot. I debugged this by turning off the matrix boxes completely, then adding it back piece by piece. The eager-loading alone is only like 1 to 1.5 seconds on my laptop. But by time I re-enabled all of the carousel stuff it was up to about 3.5 seconds. This is all 100% rendering time, not database time. And no partials are involved either. Just pure, straight ruby. And lots of it. This has become very complex. Not sure how to fix it. I'm pushing my changes now. |
@pellaea thanks for checking this out so thoroughly. I will merge some of those last tweaks into main tomorrow, after examining more closely - they should probably go independently. Question - do we need the image copyright info on the index lightbox? I knew this was a doozy of a multiple join. The question is, can we ditch it here? Cache it on a column? This PR has certainly shed light if nothing else. Might be a good opportunity to try out ViewComponents. I can make a PR off this branch turning the obs matrix box partial and helpers into VC's, and we compare speed then. |
I couldn't get VirtualBox working when I first got my M1. I tried Docker, but it increased the time it took for tests to run to something like 20 mins. I tweaked it a bit and it got a bit better, but never back to the level it had been using VirtualBox. I then ran into this weird RedCloth issue using Docker on M1, so I threw in the towel and just ran it natively. It's so fast, I haven't looked back. Another good metric that might be worth comparing is that for me the full test suite runs in under 2 minutes:
|
It looks like Jason's fix got rid of the weird queries. It's still noticeably slower (2.5 seconds vs. 1.5 seconds). The most noticeable thing is the image relead when I do a hard reload. On main it still must be using some sort of cache since it only adds about half a second. However, on the branch it takes a full minute to load the images for the 144 observations. All of that is browser time, so I'm a bit more concerned about the server load time, but I'd be ok with at least trying it out. |
Very interesting point about image loading. I thought we were lazy-loading image? But the observation about the page being almost twice as slow is comparable to my own observation. I don't think the extra includes (observation -> projects, images -> users, images -> projects) add significantly to the query time. Initially I ripped out all of the includes that I could, assuming that was going to help. But surprisingly, even after all of that I was still seeing the same ca. 3.5 second page load. Maybe a quarter of a second faster without several extra eager-loads? Not worth the extra complexity required to render different content on some pages than on other pages, in my opinion. So I just left those two "XXX consider dropping these on indexes" comments, but otherwise reverted as far as I could to Nimmo's original code. Because it was useful seeing where those projects were required. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Having these carousels is always going to be a tradeoff between avoiding round-trips to show obs, and slowing down the index itself. The carousels will always be slower, the question is if it's tolerable. I kind of feel like it is, although I'm not crazy about them. However, maybe this should wait until i can rewrite the image partials as ViewComponents. That should speed up the index quite a lot — then maybe the carousels will not make the higher load time intolerable. |
Check it out. Rudimentary!