[go: up one dir, main page]

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

Minor changes to reduce allocations #848

Merged
merged 12 commits into from
Feb 20, 2019
Merged

Conversation

Bond-009
Copy link
Member
@Bond-009 Bond-009 commented Feb 9, 2019

Reduces stress on the GC

public static IDisposable Read(this ReaderWriterLockSlim obj)
{
//if (BaseSqliteRepository.ThreadSafeMode > 0)
//{
// return new DummyToken();
//}
return new WriteLockToken(obj);
return new WriteLockToken(obj); // TODO: fix segfault
Copy link
Contributor

Choose a reason for hiding this comment

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

this message should be expanded, something like "fix segfault if using Read/Write lock"

Copy link
Member Author

Choose a reason for hiding this comment

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

I took a closer look at the db code and figured out the reason, I'll try and restructure all databases when my current big PRs are in.

Copy link
Contributor

Choose a reason for hiding this comment

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

Still this TODO should be either reformulated to be clear or removed altogether.

Jellyfin.Server/Jellyfin.Server.csproj Outdated Show resolved Hide resolved
Jellyfin.Server/SocketSharp/WebSocketSharpRequest.cs Outdated Show resolved Hide resolved
Copy link
Contributor
@JustAMan JustAMan left a comment

Choose a reason for hiding this comment

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

@Bond-009 you got me convinced.
LGTM!

Copy link
Member
@EraYaN EraYaN left a comment

Choose a reason for hiding this comment

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

LGTM


#if DEBUG
slowThreshold = 250;
slowThreshold = 10;
Copy link
Member

Choose a reason for hiding this comment

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

These values should probably be documented and maybe even put in a central file.

Copy link
Member Author

Choose a reason for hiding this comment

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

Before we document them, we should agree on the values

Copy link
Member

Choose a reason for hiding this comment

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

The values make sense to me. It will produce a lot of warnings in DEBUG, but seeing as we want to optimize it anyway, it's fine with me.

@@ -2957,6 +2949,7 @@ private string GetOrderByText(InternalItemsQuery query)
{
var columnMap = MapOrderByField(i.Item1, query);
var columnAscending = i.Item2 == SortOrder.Ascending;
const bool enableOrderInversion = false;
Copy link
Member
@EraYaN EraYaN Feb 18, 2019

Choose a reason for hiding this comment

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

If this is false, the if statement below this can be removed.

Copy link
Member Author

Choose a reason for hiding this comment

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

enableOrderInversion was already always false, it can be removed in another PR

@joshuaboniface joshuaboniface merged commit 89d4ce3 into jellyfin:master Feb 20, 2019
@Lynxy
Copy link
Contributor
Lynxy commented Mar 2, 2019

I've been having trouble with Kodi syncing TV Shows and narrowed the issue down to this commit as it works fine prior to this.

Trying to sync TV results in a dialog box saying "Something went wrong during the sync. You'll be able to restore progress when restarting Kodi. If the problem persists, please report on the Jellyfin for Kodi forums, with your Kodi log."

The message indicates I should restart Kodi but that does not help at all. Tested on both Kodi 18.1 and 17.6.

Here is the log from kodi.log when this occurs:

NOTICE: JELLYFIN.helper.wrapper -> Processing TV Shows: 7457ffe4f17493ef374c0545ad496a4e
NOTICE: JELLYFIN.objects.tvshows -> UPDATE tvshow [2/1] Media Name Redacted: 5b39e58f5df97113c8e9216ab3ec56e1
NOTICE: JELLYFIN.database -> ERROR:: type: <type 'exceptions.KeyError'> value: 'SeriesId'
NOTICE: JELLYFIN.database -> [jellyfin] 1 rows updated.
NOTICE: JELLYFIN.database -> ERROR:: type: <type 'exceptions.KeyError'> value: 'SeriesId'
NOTICE: JELLYFIN.database -> [video] 32 rows updated.

@Lynxy
Copy link
Contributor
Lynxy commented Mar 2, 2019

Here is some debug data from the Jellyfin for Kodi addon. I know this is not the repository for that, however since this commit broke it please bear with me.

This exception occurs in the loop in plugin.video.jellyfin/jellyfin/objects/tvshows.py:139.

Here is the value of season prior to this commit:

{'SpecialFeatureCount': 0, 'Genres': [], 'CanDelete': False, 'LocationType': 'FileSystem', 'LocalTrailerCount': 0, 'CanDownload': False, 'ExternalUrls': [], 'Etag': '16ce0ea676474934e49c58fb2ff47719', 'ParentLogoImageTag': '4aa4a1be8326fc683c86b59873aef391', 'ScreenshotImageTags': [], 'RemoteTrailers': [], 'ParentBackdropImageTags': ['92d764ee0b343a86a4b5aecf8da217f4'], 'ServerId': '4d0ac52d083f2915952051a645b9930b', 'Type': 'Season', 'SortName': '0001', 'SeriesId': 'ccb9e58252f971d588e92c2cb3ec7311', 'PlayAccess': 'Full', 'Tags': [], 'IsFolder': True, 'LockedFields': [], 'EnableMediaSourceDisplay': True, 'ProviderIds': {}, 'PremiereDate': '1990-01-01T05:00:00.0000000Z', 'ProductionYear': 1990, 'DisplayPreferencesId': 'dfd065f5787fb957a750d76dcf835aad', 'Path': '/media/path/redacted/Season 1', 'BackdropImageTags': [], 'Name': 'Season 1', 'SeriesStudio': 'redacted', 'LockData': False, 'SeriesName': 'Media Name Redacted', 'Taglines': [], 'ParentId': 'ccb9e58252f971d588e92c2cb3ec7311', 'PrimaryImageAspectRatio': 0.666666666666667, 'ParentLogoItemId': 'ccb9e58252f971d588e92c2cb3ec7311', 'ChildCount': 5, 'UserData': {'IsFavorite': False, 'Played': False, 'PlayedPercentage': 0, 'UnplayedItemCount': 5, 'PlaybackPositionTicks': 0, 'Key': '78886001', 'PlayCount': 0}, 'Studios': [], 'IndexNumber': 1, 'People': [], 'SeriesPrimaryImageTag': '62f0b841bfddcbeabe8a15caf7bed7fb', 'DateCreated': '2017-09-09T01:42:11.0000000Z', 'ParentBackdropItemId': 'ccb9e58252f971d588e92c2cb3ec7311', 'ImageTags': {'Primary': 'a7bd2d4acd11d6e60b789f0a793b66b5'}, 'GenreItems': [], 'RecursiveItemCount': 5, 'Id': '2c2636bf0666962ce563705eda7de9f4'}

And here is the value of season with this commit:

{'SpecialFeatureCount': 0, 'Genres': [], 'CanDelete': False, 'LocationType': 'FileSystem', 'LocalTrailerCount': 0, 'CanDownload': False, 'ExternalUrls': [], 'Etag': '16ce0ea676474934e49c58fb2ff47719', 'ParentLogoImageTag': '4aa4a1be8326fc683c86b59873aef391', 'ScreenshotImageTags': [], 'RemoteTrailers': [], 'ParentBackdropImageTags': ['92d764ee0b343a86a4b5aecf8da217f4'], 'ServerId': '4d0ac52d083f2915952051a645b9930b', 'Type': 'Season', 'SortName': '0001', 'PlayAccess': 'Full', 'Tags': [], 'IsFolder': True, 'LockedFields': [], 'EnableMediaSourceDisplay': True, 'ProviderIds': {}, 'PremiereDate': '1990-01-01T05:00:00.0000000Z', 'ProductionYear': 1990, 'DisplayPreferencesId': 'dfd065f5787fb957a750d76dcf835aad', 'Path': '/media/path/redacted/Season 1', 'BackdropImageTags': [], 'Name': 'Season 1', 'SeriesStudio': 'redacted', 'LockData': False, 'SeriesName': 'Media Name Redacted', 'Taglines': [], 'PrimaryImageAspectRatio': 0.666666666666667, 'ParentLogoItemId': 'ccb9e58252f971d588e92c2cb3ec7311', 'ChildCount': 5, 'UserData': {'IsFavorite': False, 'Played': False, 'PlayedPercentage': 0, 'UnplayedItemCount': 5, 'PlaybackPositionTicks': 0, 'Key': '78886001', 'PlayCount': 0}, 'Studios': [], 'IndexNumber': 1, 'People': [], 'SeriesPrimaryImageTag': '62f0b841bfddcbeabe8a15caf7bed7fb', 'DateCreated': '2017-09-09T01:42:11.0000000Z', 'ParentBackdropItemId': 'ccb9e58252f971d588e92c2cb3ec7311', 'ImageTags': {'Primary': 'a7bd2d4acd11d6e60b789f0a793b66b5'}, 'GenreItems': [], 'RecursiveItemCount': 5, 'Id': '2c2636bf0666962ce563705eda7de9f4'}

The keys SeriesId and ParentId are missing.

@Lynxy
Copy link
Contributor
Lynxy commented Mar 2, 2019

I have further narrowed this down to commit 64d5ec1. I can be on HEAD and revert that commit and it works just fine like it use to.

I am not familiar with what this PR is trying to accomplish and am having difficulty understanding the changes. Perhaps someone more familiar with it could chime in with why this is happening?

@Lynxy
Copy link
Contributor
Lynxy commented Mar 2, 2019

I have found the issue.

In file Emby.Server.Implementations/Data/SqliteItemRepository.cs:2280, the line that sets HashSet<string> _seriesTypes, it looks like the values were duplicated from _artistsTypes above and never properly changed to the correct values for a series. I will follow up with a new PR correcting this.

@JustAMan
Copy link
Contributor
JustAMan commented Mar 6, 2019

@Lynxy thanks for the debugging and finding the root cause!

@Bond-009 Bond-009 deleted the perf branch July 24, 2019 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants